<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http//www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0041)./Manage.html -->
<html xmlns="http//www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>榆林科技馆内容页</title>
    <link rel="stylesheet" type="text/css" href="../css/reset.css">
    <link rel="stylesheet" type="text/css" href="../css/main.css">
    <script type="text/javascript" src="./js/adddate.js.下载"></script>
    <script src="../js/vue2.min.js"></script>
    <script src="../js/axios.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function (e) {
            $(".select1").uedSelect({
                width: 345
            });
            $(".select2").uedSelect({
                width: 167
            });
            $(".select3").uedSelect({
                width: 100
            });
        });

        function checkAll(chkAllID, thisObj) {
            var chkAll = document.getElementById(chkAllID);
            var chks = document.getElementsByTagName("input");
            var chkNo = 0;
            var selectNo = 0;
            for (var i = 0; i < chks.length; i++) {
                if (chks[i].type == "checkbox") {
                    //全选触发事件
                    if (chkAll == thisObj) {
                        chks[i].checked = thisObj.checked;
                    }
                    //非全选触发
                    else {
                        if (chks[i].checked && chks[i].id != chkAllID)
                            selectNo++;
                    }
                    if (chks[i].id != chkAllID) {
                        chkNo++;
                    }
                }
            }
            if (chkAll != thisObj) {
                chkAll.checked = chkNo == selectNo;
            }
        }
    </script>
</head>

<body>
<!--条件检索-->
<form name="form" method="post"  id="form">
    <div id="manageList">


        <script type="text/javascript">
            //<![CDATA[
            var theForm = document.forms['form'];
            if (!theForm) {
                theForm = document.form;
            }

            function __doPostBack(eventTarget, eventArgument) {
                if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
                    theForm.__EVENTTARGET.value = eventTarget;
                    theForm.__EVENTARGUMENT.value = eventArgument;
                    theForm.submit();
                }
            }

            //]]>
        </script>


        <div class="main_box">
            <div class="side_here">
                <p>
                    <a href="./Manage.html#" title="首页"></a>当前位置 &gt; <span>科技馆场次管理</span> &gt; <span>场次信息管理</span></p>
            </div>
            <div class="kong">
            </div>
            <!--公用位置导航结束-->
            <div class="cont_box">
                <p class="title_bt">
                    条件查询</p>
                <table class="table_list1" border="0" cellspacing="0" cellpadding="0">
                    <tbody>
                    <tr>
                        <td class="name">
                            开馆日期：
                        </td>
                        <td class="enter3">
                            <input name="TextBox2" type="text" id="TextBox2" class="timeimg" placeholder="时间不能留空"
                                   onclick="SelectDate(this,&#39;yyyy-MM-dd&#39;)">
                        </td>
                        <td class="name">
                            审核状态：
                        </td>
                        <td class="enter3">
                            <select name="DropDownList1" id="DropDownList1" class="enter_k" placeholder="请选择">
                                <option value="2">--请选择--</option>
                                <option value="1">已审核</option>
                                <option value="0">未审核</option>

                            </select>
                        </td>
                        <td>
<!--                            <button onclick="findByTimeAndIs()" class="chaxun">查询</button>-->
<!--                            <button onclick="findByTimeAndIs()">sdfa</button>-->
                            <input type="button" onclick="findByTimeAndIs()" value="查询" class="chaxun"/>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
            <!--表格选项-->
            <div class="cont_box">
                <p class="title_bt">
                    场次列表</p>
                <table width="1060" border="0" cellpadding="0" cellspacing="0" class="table_list2">
                    <tbody >
                    <tr>
                        <th width="6%">
                            全选&nbsp;<input class="qx_btn" type="checkbox" id="chkAll" name="chkAll" value="checkbox"
                                           onclick="checkAll   (&#39;chkAll&#39;,this);">
                        </th>
                        <th width="15%">
                            开馆日期
                        </th>
                        <th width="6%">
                            容纳人数
                        </th>
                        <th width="15%">
                            开馆时间
                        </th>
                        <th width="15%">
                            闭馆时间
                        </th>
                        <th width="18%">
                            预约状态
                        </th>
                        <th width="15%">
                            操作
                        </th>
                    </tr>

                    <tr v-for="s in manages">
                        <td>
                            <input  type="checkbox" name="scidCheck"   onclick="checkAll('chkAll',this)"  :id="'Repeater'+s.scid" :value="s.scid" :text="s.scid">
                        </td>
                        <td>{{s.openDate}}</td>
                        <td>{{s.maxCapacity}}</td>
                        <td>{{s.openTime}}</td>
                        <td>{{s.closeTime}}</td>
                        <td>{{s.isaudit}}</td>
                        <td>
                            <a :href="'Edit.html?scid='+s.scid" ><input type="button" class="btn_an btn_config" title="编辑"/></a>
                            <input type="button" class="btn btn_an btn_del" @click="deleteSrc(s.scid)" title="删除">
                            <input type="button" class="btn btn_an btn_checked" @click="checkSrc(s.scid)" title="审核">
                        </td>
                    </tr>
                    </tbody>
                </table>
                <input type="button" name="pi" value="批量审核" id="pi" class="chaxun" onclick="detectAll()"
                       style="width:94px;margin-left: 500px; margin-top: 30px;">
                <!--页码开始-->
                <div class="pages" style="margin-top: 40px;">
                    <ul class="yema">
                        <li style="border-left: none;">
                            <a id="Lbthead" class="pagebtn"
                               href="javascript:__doPostBack(&#39;Lbthead&#39;,&#39;&#39;)">首页</a></li>
                        <li>
                            <a id="Lbtpre" class="pagebtn" href="javascript:__doPostBack(&#39;Lbtpre&#39;,&#39;&#39;)">上一页</a>
                        </li>
                        <li>
                            <a id="Lbtnext" class="pagebtn"
                               href="javascript:__doPostBack(&#39;Lbtnext&#39;,&#39;&#39;)">下一页</a></li>
                        <li>
                            <a id="Lbtend" class="pagebtn" href="javascript:__doPostBack(&#39;Lbtend&#39;,&#39;&#39;)">尾页</a>
                        </li>
                        <div class="clear">
                        </div>
                    </ul>
                    <div class="searchPage">
                    <span class="page-sum">共<strong class="allPage">&nbsp;76
                    </strong>页</span><span class="page-sum">第<strong class="allPage">&nbsp;1
                    </strong>页</span> <span class="page-go">跳转第
                        <input name="Txtpageno" type="text" id="Txtpageno" class="pagebtn" size="3"
                               onkeyup="this.value=this.value.replace(/[^\d\.]/g, &#39;&#39;)"
                               style="ime-mode: disabled">页</span>
                        <a id="BtngoPage" class="page-btn"
                           href="javascript:__doPostBack(&#39;BtngoPage&#39;,&#39;&#39;)">GO</a>
                    </div>
                    <div class="clear">
                    </div>
                </div>
            </div>
        </div>


        <!--页码结束-->
        <!--按钮元素-->
</form>
</body>
<script>
    fimlapp= new Vue({
        el:"#manageList",
        data:{
            manages:[]
        },
        methods : {
            deleteSrc:function(id) {
                if (window.confirm("是否确认删除")){
                    axios.get("../SrcServlet?action=deleteSrc&scid="+id).then(res=>{
                        console.log(res.data);
                        // this.manages.remove(res.data);
                        if (res.data!=null) {
                            let index = this.manages.findIndex((ele) => {
                                return ele.id === id;
                            });
                            this.manages.splice(index, 1);
                        }
                    })
                }
            },
            checkSrc : function(id) {

                if (window.confirm("是否确认审批")){
                    axios.get("../SrcServlet?action=checkSrc&scid="+id).then(res=>{
                        console.log(res.data);
                        // this.manages.remove(res.data);
                        if (res.data=="success") {
                           for (var i = 0; i <this.manages.length; i++) {
                               if (this.manages[i].scid == id) {
                                   this.manages[i].isaudit="已审核";
                                   break;
                               }
                           }
                        }
                    })
                }
            }
        }
    });

    function findByTimeAndIs() {
        var time=document.getElementById("TextBox2").value;
        var ischeck=document.getElementById("DropDownList1").value;
        var url="../SrcServlet?action=selectTimeAndIsaudit&time="+time+"&isaudit="+ischeck;
        axios.get(url).then(res=>{
            // alert("jjkbkjbkj")
            console.log(res);
            fimlapp.manages=res.data;
        });
    }

    window.onload = init;
    // window.onbeforeunload = init;
    function init() {
        axios.get("../SrcServlet?action=selectSrc").then(res=>{
            console.log(res);
            fimlapp.manages=res.data;
        });
    }

    function detectAll(){
       var  ca =document.getElementsByName("scidCheck");
       var str=""
       for (var i = 0; i < ca.length;i++) {
           if (ca[i].checked) {
               if(str==""){
                   str += ca[i].value;
               }else {
                   str += ","
                   str += ca[i].value;
               }
           }
       }
       if (str==""){
           alert("至少选中一项")
       }else {
           axios.get("../SrcServlet?action=detectAll&det="+str).then(res=>{
               if (res.data=="success"){
                   for (var i = 0; i < ca.length;i++){
                       if (ca[i].checked) {
                           fimlapp.manages[i].isaudit="已审核";
                       }
                   }
               }
           });
       }
    }

</script>
</html>